WTO_GROUP_TYPES = ['WTO coalition','cross-coalition','non-WTO'];
WTO_GROUP_PURPOSES = ['offensive','defensive','regional','managerial'];

var id = function(id) { return document.getElementById(id); }

var html = function(tag, opt_attribs, opt_child) {
  var result = document.createElement(tag);

  if (opt_attribs) {
    for (var key in opt_attribs) {
      result[key] = opt_attribs[key];
    }
  }

  if (typeof(opt_child) == "string") {
    result.innerHTML = opt_child;
  } else if (typeof(opt_child) == "object") {
    result.appendChild(opt_child);
  }
  return result;
}                                                                                                                                           
$$ = {
  "make": function(tag) { return document.createElement(tag); },
  "get": function(id) { return document.getElementById(id); },
  "clear": function(element) {
    while (element.hasChildNodes()) {
      element.removeChild(element.lastChild);
    }
  },
  "keys": function(obj) { 
    var result = [];
    if (obj) {
      for (var i in obj) { result.push(i); } 
    }
    return result;
  },
  "values": function(obj) { 
    var result = [];
    if (obj) {
      for (var i in obj) { result.push(obj[i]); } 
    }
    return result;
  }
};

String.prototype.startsWith = function(val) {
  return this.substring(0, val.length) == val;
}
